﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="../assets/css/yui-cssgrids-min.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="shortcut icon" type="image/x-icon" href="../assets/favicon.ico">
    <script src="../assets/js/yui-source.js"></script>
	<title>SoundJS v1.0.0 API Documentation : Utility Methods</title>
</head>
<body class="yui3-skin-sam">

<div id="doc">
    <div id="hd" class="yui3-g header">
        <div class="yui3-u-3-4">
            
                <h1><a href="http://createjs.site/soundjs"><img src="../assets/docs-icon-SoundJS.png" title="SoundJS"></a></h1>
            
        </div>
        <div class="yui3-u-1-4 version">
            <em>API Documentation for: 1.0.0</em>
        </div>
    </div>
    <div id="bd" class="yui3-g">

        <div class="yui3-u-1-4">
            <div id="docs-sidebar" class="sidebar apidocs">
                <div id="api-list">
    <h2 class="off-left">APIs</h2>
    <div id="api-tabview" class="tabview">
        <ul class="tabs">
            <li><a href="#api-classes">Classes</a></li>
        </ul>

        <div id="api-tabview-filter">
            <input type="search" id="api-filter" placeholder="Type to filter APIs">
        </div>

        <div id="api-tabview-panel">
            <ul id="api-classes" class="apis classes">
            
                <li><a href="AbstractPlugin.html">AbstractPlugin</a></li>
            
                <li><a href="AbstractSoundInstance.html">AbstractSoundInstance</a></li>
            
                <li><a href="AudioSprite.html">AudioSprite</a></li>
            
                <li><a href="CordovaAudioLoader.html">CordovaAudioLoader</a></li>
            
                <li><a href="CordovaAudioPlugin.html">CordovaAudioPlugin</a></li>
            
                <li><a href="CordovaAudioSoundInstance.html">CordovaAudioSoundInstance</a></li>
            
                <li><a href="ErrorEvent.html">ErrorEvent</a></li>
            
                <li><a href="Event.html">Event</a></li>
            
                <li><a href="EventDispatcher.html">EventDispatcher</a></li>
            
                <li><a href="FlashAudioLoader.html">FlashAudioLoader</a></li>
            
                <li><a href="FlashAudioPlugin.html">FlashAudioPlugin</a></li>
            
                <li><a href="FlashAudioSoundInstance.html">FlashAudioSoundInstance</a></li>
            
                <li><a href="HTMLAudioPlugin.html">HTMLAudioPlugin</a></li>
            
                <li><a href="HTMLAudioSoundInstance.html">HTMLAudioSoundInstance</a></li>
            
                <li><a href="HTMLAudioTagPool.html">HTMLAudioTagPool</a></li>
            
                <li><a href="PlayPropsConfig.html">PlayPropsConfig</a></li>
            
                <li><a href="Sound.html">Sound</a></li>
            
                <li><a href="SoundJS.html">SoundJS</a></li>
            
                <li><a href="Utility%20Methods.html">Utility Methods</a></li>
            
                <li><a href="WebAudioLoader.html">WebAudioLoader</a></li>
            
                <li><a href="WebAudioPlugin.html">WebAudioPlugin</a></li>
            
                <li><a href="WebAudioSoundInstance.html">WebAudioSoundInstance</a></li>
            
            </ul>

            <ul id="api-modules" class="apis modules">
            
                <li><a href="../modules/CreateJS.html">CreateJS</a></li>
            
                <li><a href="../modules/SoundJS.html">SoundJS</a></li>
            
            </ul>
        </div>
    </div>
</div>

            </div>
        </div>
        <div class="yui3-u-3-4">
            <div id="api-options">
        Show:
        <label for="api-show-inherited">
            <input type="checkbox" id="api-show-inherited" checked="">
            Inherited
        </label>

        <label for="api-show-protected">
            <input type="checkbox" id="api-show-protected">
            Protected
        </label>

        <label for="api-show-private">
            <input type="checkbox" id="api-show-private">
            Private
        </label>
        <label for="api-show-deprecated">
            <input type="checkbox" id="api-show-deprecated">
            Deprecated
        </label>

    </div>
            <div class="apidocs">
                <div id="docs-main">
                    <div class="content">
                        <h1>Utility Methods Class</h1>
<div class="box meta">
    

    

    
        <div class="foundat">
            Defined in: <a href="../files/createjs_utils_proxy.js.html#l36"><code>Utility Methods:36</code></a>
        </div>
    

    
        
            Module: <a href="../modules/CreateJS.html">CreateJS</a>
        
    

    
</div>



<div class="box intro">
    <p>Various utilities that the CreateJS Suite uses. Utilities are created as separate files, and will be available on the
createjs namespace directly.</p>
<h4>Example</h4>

<pre class="code prettyprint"><code> myObject.addEventListener("change", createjs.proxy(myMethod, scope));</code></pre>

</div>



<div id="classdocs" class="tabview">
    <ul class="api-class-tabs">
        <li class="api-class-tab index"><a href="#index">Index</a></li>

        
            <li class="api-class-tab methods"><a href="#methods">Methods</a></li>
        
        
            <li class="api-class-tab properties"><a href="#properties">Properties</a></li>
        
        
        
    </ul>

    <div>
        <div id="index" class="api-class-tabpanel index">
            <h2 class="off-left">Item Index</h2>

            
                <div class="index-section methods">
                    <h3>Methods</h3>

                    <ul class="index-list methods">
                        
                            <li class="index-item method">
                                <a href="#method_deprecate">deprecate</a>

                                
                                
                            </li>
                        
                            <li class="index-item method">
                                <a href="#method_extend">extend</a>

                                
                                
                            </li>
                        
                            <li class="index-item method">
                                <a href="#method_indexOf">indexOf</a>

                                
                                
                            </li>
                        
                            <li class="index-item method">
                                <a href="#method_promote">promote</a>

                                
                                
                            </li>
                        
                            <li class="index-item method public">
                                <a href="#method_proxy">proxy</a>

                                
                                    <span class="flag static">static</span>
                                
                                
                            </li>
                        
                    </ul>
                </div>
            

            
                <div class="index-section properties">
                    <h3>Properties</h3>

                    <ul class="index-list properties">
                        
                            <li class="index-item property">
                                <a href="#property_BrowserDetect">BrowserDetect</a>

                                
                                    <span class="flag static">static</span>
                                
                                
                            </li>
                        
                    </ul>
                </div>
            

            

            
        </div>

        
            <div id="methods" class="api-class-tabpanel">
                <h2 class="off-left">Methods</h2>

                
                    <div id="method_deprecate" class="method item">
    <h3 class="name"><code>deprecate</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code class="optional">[fallbackMethod=null]</code>
                    
                </li>
            
                <li class="arg">
                    
                        <code class="optional">[name=null]</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    
        <span class="returns-inline">
            <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span>
        </span>
    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/createjs_utils_deprecate.js.html#l40"><code>deprecate:40</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>Wraps deprecated methods so they still be used, but throw warnings to developers.</p>
<pre class="code prettyprint"><code>obj.deprecatedMethod = createjs.deprecate("Old Method Name", obj._fallbackMethod);</code></pre>
<p>The recommended approach for deprecated properties is:</p>
<pre class="code prettyprint"><code>try {
    Obj    ect.defineProperties(object, {
        readyOnlyProp: { get: createjs.deprecate("readOnlyProp", function() { return this.alternateProp; }) },
        readWriteProp: {
            get: createjs.deprecate("readOnlyProp", function() { return this.alternateProp; }),
            set: createjs.deprecate("readOnlyProp", function(val) { this.alternateProp = val; })
    });
} catch (e) {}</code></pre>

    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name optional">[fallbackMethod=null]</code>
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                        <p>A method to call when the deprecated method is used. See the example for how</p>

                    </div>

                    
                </li>
            
                <li class="param">
                    
                        <code class="param-name optional">[name=null]</code>
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a></span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                        <p>The name of the method or property to display in the console warning.
to deprecate properties.</p>

                    </div>

                    
                </li>
            
            </ul>
        </div>
    

    
        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                
                    
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span>:
                    
                    <p>If a fallbackMethod is supplied, returns a closure that will call the fallback method after
logging the warning in the console.</p>

                
            </div>
        </div>
    

    
</div>

                
                    <div id="method_extend" class="method item">
    <h3 class="name"><code>extend</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code>subclass</code>
                    
                </li>
            
                <li class="arg">
                    
                        <code>superclass</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    
        <span class="returns-inline">
            <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span>
        </span>
    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/createjs_utils_extend.js.html#l40"><code>extend:40</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>Sets up the prototype chain and constructor property for a new class.</p>
<p>This should be called right after creating the class constructor.</p>
<pre class="code prettyprint"><code>function MySubClass() {}
createjs.extend(MySubClass, MySuperClass);
MySubClass.prototype.doSomething = function() { }

var foo = new MySubClass();
console.log(foo instanceof MySuperClass); // true
console.log(foo.prototype.constructor === MySubClass); // true</code></pre>

    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name">subclass</code>
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span>
                    

                    

                    <div class="param-description">
                        <p>The subclass.</p>

                    </div>

                    
                </li>
            
                <li class="param">
                    
                        <code class="param-name">superclass</code>
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span>
                    

                    

                    <div class="param-description">
                        <p>The superclass to extend.</p>

                    </div>

                    
                </li>
            
            </ul>
        </div>
    

    
        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                
                    
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span>:
                    
                    <p>Returns the subclass&#39;s new prototype.</p>

                
            </div>
        </div>
    

    
</div>

                
                    <div id="method_indexOf" class="method item">
    <h3 class="name"><code>indexOf</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code>array</code>
                    
                </li>
            
                <li class="arg">
                    
                        <code>searchElement</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    
        <span class="returns-inline">
            <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>
        </span>
    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/createjs_utils_indexOf.js.html#l40"><code>indexOf:40</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>Finds the first occurrence of a specified value searchElement in the passed in array, and returns the index of
that value.  Returns -1 if value is not found.</p>
<pre class="code prettyprint"><code> var i = createjs.indexOf(myArray, myElementToFind);</code></pre>

    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name">array</code>
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array" class="crosslink external" target="_blank">Array</a></span>
                    

                    

                    <div class="param-description">
                        <p>Array to search for searchElement</p>

                    </div>

                    
                </li>
            
                <li class="param">
                    
                        <code class="param-name">searchElement</code>
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object" class="crosslink external" target="_blank">Object</a></span>
                    

                    

                    <div class="param-description">
                        <p>Element to find in array.</p>

                    </div>

                    
                </li>
            
            </ul>
        </div>
    

    
        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                
                    
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number" class="crosslink external" target="_blank">Number</a></span>:
                    
                    <p>The first index of searchElement in array.</p>

                
            </div>
        </div>
    

    
</div>

                
                    <div id="method_promote" class="method item">
    <h3 class="name"><code>promote</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code>subclass</code>
                    
                </li>
            
                <li class="arg">
                    
                        <code>prefix</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    
        <span class="returns-inline">
            <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span>
        </span>
    

    

    

    

    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/createjs_utils_promote.js.html#l40"><code>promote:40</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>Promotes any methods on the super class that were overridden, by creating an alias in the format <code>prefix_methodName</code>.
It is recommended to use the super class&#39;s name as the prefix.
An alias to the super class&#39;s constructor is always added in the format <code>prefix_constructor</code>.
This allows the subclass to call super class methods without using <code>function.call</code>, providing better performance.</p>
<p>For example, if <code>MySubClass</code> extends <code>MySuperClass</code>, and both define a <code>draw</code> method, then calling <code>promote(MySubClass, "MySuperClass")</code>
would add a <code>MySuperClass_constructor</code> method to MySubClass and promote the <code>draw</code> method on <code>MySuperClass</code> to the
prototype of <code>MySubClass</code> as <code>MySuperClass_draw</code>.</p>
<p>This should be called after the class&#39;s prototype is fully defined.</p>
<pre class="code prettyprint"><code>function ClassA(name) {
    this.name = name;
}
ClassA.prototype.greet = function() {
    return "Hello "+this.name;
}

function ClassB(name, punctuation) {
    this.ClassA_constructor(name);
    this.punctuation = punctuation;
}
createjs.extend(ClassB, ClassA);
ClassB.prototype.greet = function() {
    return this.ClassA_greet()+this.punctuation;
}
createjs.promote(ClassB, "ClassA");

var foo = new ClassB("World", "!?!");
console.log(foo.greet()); // Hello World!?!</code></pre>

    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name">subclass</code>
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span>
                    

                    

                    <div class="param-description">
                        <p>The class to promote super class methods on.</p>

                    </div>

                    
                </li>
            
                <li class="param">
                    
                        <code class="param-name">prefix</code>
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String" class="crosslink external" target="_blank">String</a></span>
                    

                    

                    <div class="param-description">
                        <p>The prefix to add to the promoted method names. Usually the name of the superclass.</p>

                    </div>

                    
                </li>
            
            </ul>
        </div>
    

    
        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                
                    
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span>:
                    
                    <p>Returns the subclass.</p>

                
            </div>
        </div>
    

    
</div>

                
                    <div id="method_proxy" class="method item public">
    <h3 class="name"><code>proxy</code></h3>

    
        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
            
                <li class="arg">
                    
                        <code>method</code>
                    
                </li>
            
                <li class="arg">
                    
                        <code>scope</code>
                    
                </li>
            
                <li class="arg">
                    
                        <code class="optional">[arg]</code>
                    
                </li>
            
            </ul><span class="paren">)</span>
        </div>
    

    

    

    
        <span class="flag public">public</span>
    

    

    
        <span class="flag static">static</span>
    

    

    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/createjs_utils_proxy.js.html#l51"><code>proxy:51</code></a>
        
        </p>


        

        
    </div>

    <div class="description">
        <p>A function proxy for methods. By default, JavaScript methods do not maintain scope, so passing a method as a
callback will result in the method getting called in the scope of the caller. Using a proxy ensures that the
method gets called in the correct scope.</p>
<p>Additional arguments can be passed that will be applied to the function when it is called.</p>
<h4>Example</h4>

<pre class="code prettyprint"><code> myObject.addEventListener("event", createjs.proxy(myHandler, this, arg1, arg2));

 function myHandler(arg1, arg2) {
      // This gets called when myObject.myCallback is executed.
 }</code></pre>

    </div>

    
        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
            
                <li class="param">
                    
                        <code class="param-name">method</code>
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function" class="crosslink external" target="_blank">Function</a></span>
                    

                    

                    <div class="param-description">
                        <p>The function to call</p>

                    </div>

                    
                </li>
            
                <li class="param">
                    
                        <code class="param-name">scope</code>
                        <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object" class="crosslink external" target="_blank">Object</a></span>
                    

                    

                    <div class="param-description">
                        <p>The scope to call the method name on</p>

                    </div>

                    
                </li>
            
                <li class="param">
                    
                        <code class="param-name optional">[arg]</code>
                        <span class="type">Mixed</span>
                        <span class="flag optional" title="This parameter is optional.">optional</span>
                    

                    

                    <div class="param-description">
                        <ul>
<li>Arguments that are appended to the callback for additional params.</li>
</ul>

                    </div>

                    
                </li>
            
            </ul>
        </div>
    

    

    
</div>

                
            </div>
        

        
            <div id="properties" class="api-class-tabpanel">
                <h2 class="off-left">Properties</h2>

                
                    <div id="property_BrowserDetect" class="property item">
    <h3 class="name"><code>BrowserDetect</code></h3>
    <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object" class="crosslink external" target="_blank">Object</a></span>

    

    

    

    
        <span class="flag static">static</span>
    

    <div class="meta">
        
            
                
                <p>
                
                Defined in
                
            
        
        
        <a href="../files/createjs_utils_BrowserDetect.js.html#l42"><code>BrowserDetect:42</code></a>
        
        </p>

        

        
    </div>

    <div class="description">
        <p>An object that determines the current browser, version, operating system, and other environment
variables via user agent string.</p>
<p>Used for audio because feature detection is unable to detect the many limitations of mobile devices.</p>
<h4>Example</h4>

<pre class="code prettyprint"><code> if (createjs.BrowserDetect.isIOS) { // do stuff }</code></pre>

    </div>

    

    

    
        <h4>Sub-properties:</h4>

        <ul class="params-list">
            
            <li class="param">
                
                    <code class="param-name">isFirefox</code>
                    <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span>
                

                <div class="param-description">
                    <p>True if our browser is Firefox.</p>

                </div>

                
            </li>
            
            <li class="param">
                
                    <code class="param-name">isOpera</code>
                    <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span>
                

                <div class="param-description">
                    <p>True if our browser is opera.</p>

                </div>

                
            </li>
            
            <li class="param">
                
                    <code class="param-name">isChrome</code>
                    <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span>
                

                <div class="param-description">
                    <p>True if our browser is Chrome.  Note that Chrome for Android returns true, but is a
completely different browser with different abilities.</p>

                </div>

                
            </li>
            
            <li class="param">
                
                    <code class="param-name">isIOS</code>
                    <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span>
                

                <div class="param-description">
                    <p>True if our browser is safari for iOS devices (iPad, iPhone, and iPod).</p>

                </div>

                
            </li>
            
            <li class="param">
                
                    <code class="param-name">isAndroid</code>
                    <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span>
                

                <div class="param-description">
                    <p>True if our browser is Android.</p>

                </div>

                
            </li>
            
            <li class="param">
                
                    <code class="param-name">isBlackberry</code>
                    <span class="type"><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean" class="crosslink external" target="_blank">Boolean</a></span>
                

                <div class="param-description">
                    <p>True if our browser is Blackberry.</p>

                </div>

                
            </li>
            
        </ul>
    
</div>

                
            </div>
        

        

        
    </div>
</div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>
